package io.github.definitlyevil.ziminmod.cif.armors;

import de.tr7zw.nbtapi.NBTCompound;
import de.tr7zw.nbtapi.NBTCompoundList;
import de.tr7zw.nbtapi.NBTContainer;
import de.tr7zw.nbtapi.NBTListCompound;
import io.github.definitlyevil.customitemframework.BaseItem;
import io.github.definitlyevil.customitemframework.CIFItemInstance;
import io.github.definitlyevil.ziminmod.ZiMinMod;
import org.bukkit.Material;

import java.util.Arrays;
import java.util.List;
import java.util.UUID;

public class ZiMinBoots extends BaseItem {

    private static final UUID UUID_HEALTH =
        UUID.fromString("8654cc7d-2cd7-4be7-83ce-6cdf8bdde8c1");
    private static final UUID UUID_SPEED =
        UUID.fromString("a50611d5-0b29-458a-95ba-f6d9f9c1af59");

    @Override
    public String getDisplayName(NBTCompound nbtCompound) {
        return "\u00a7e\u00a7l针男人拖鞋";
    }

    @Override
    public Material getModelMaterial() {
        return Material.DIAMOND_BOOTS;
    }

    @Override
    public int getCustomModelData(CIFItemInstance instance) {
        return 1000;
    }

    @Override
    public boolean isUnbreakable() {
        return false;
    }

    private static final List<String> LORE = Arrays.asList(
        ZiMinMod.LORE_SEPARATOR_LINE,
        "\u00a7e这个拖鞋聚集了针男人的精华，",
        "\u00a7e可以解锁很多特效！",
        ZiMinMod.LORE_SEPARATOR_LINE,
        "\u00a76装备上可以：",
        "\u00a7b- \u00a7d穿上可以为针男人提供生命和速度加成！",
        ZiMinMod.LORE_SEPARATOR_LINE
    );

    @Override
    public List<String> getLore(CIFItemInstance instance) {
        return LORE;
    }

    @Override
    public NBTContainer generateItemNBT(CIFItemInstance instance, boolean isBlock) {
        NBTContainer container = super.generateItemNBT(instance, isBlock);
        NBTCompound tag = container.getCompound("tag");
        NBTCompoundList list = tag.getCompoundList("AttributeModifiers");
        {
            NBTListCompound attribute = list.addCompound();
            attribute.setString("AttributeName", "generic.max_health");
            attribute.setString("Name", "针男人生命加成");
            attribute.setInteger("Amount", 10);   // 增加具体的量
            attribute.setInteger("Operation", 0); // 基于base来增加
            attribute.setUUID("UUID", UUID_HEALTH);
        }
        {
            NBTListCompound attribute = list.addCompound();
            attribute.setString("AttributeName", "generic.movement_speed");
            attribute.setString("Name", "针男人速度加成");
            attribute.setFloat("Amount", 0.4f);   // 增加具体的量
            attribute.setInteger("Operation", 0); // 基于base来增加
            attribute.setUUID("UUID", UUID_SPEED);
        }
        return container;
    }

    @Override
    public boolean isBlock() {
        return false;
    }
}
